package com.hubiao.basics.entity;

import com.hubiao.basics.serializable.User;
import org.junit.jupiter.api.Test;

/**
 * Description
 *
 * @author hubiao
 * @since 2021-01-22 13:51
 */
public class EntityDemo {

    @Test
    public void test01() {
        User user = new User();
        user.setHobby( "打球" );
        user.setSex( "男" );
        user.setName( "李白" );
        int a = 10;
        int b = 20;
        System.out.println( user );
        updateUser( user, a, b );
        System.out.println( user );
        System.out.println( "a = " + a + "  b=" + b );
    }


    private void updateUser(User user, int a, int b) {
        user.setName( "武则天" );
        user.setSex( "女" );
        user.setHobby( "当皇帝" );
        a = 20;
        b = 10;
        System.out.println( user );
        System.out.println( "a = " + a + "  b=" + b );
    }


    @Test
    public void test02() {
        String str1 = "HelloFlyapi";
        String str2 = "HelloFlyapi";
        String str3 = new String( "HelloFlyapi" );
        String str4 = "Hello";
        String str5 = "Flyapi";
        String str6 = "Hello" + "Flyapi";
        String str7 = str4 + str5;
        //true
        System.out.println( "str1 == str2 result: " + (str1 == str2) );
        //flase
        System.out.println( "str1 == str3 result: " + (str1 == str3) );
        //true
        System.out.println( "str1 == str6 result: " + (str1 == str6) );
        //false
        System.out.println( "str1 == str7 result: " + (str1 == str7) );
        //true
        System.out.println( "str1 == str7.intern() result: " + (str1 == str7.intern()) );
        //false
        System.out.println( "str3 == str3.intern() result: " + (str3 == str3.intern()) );
    }


}
